import { detailConfig } from '@/views/datacenter/basicData/practitioner/config'
import { getAreaObj } from '@/utils/util'

export const searchConfig = {
	inline: true,
	showBtn: true,
	labelPosition: 'left',
	labelWidth: '90px',
	column: [
		{
			label: '证件号码',
			prop: 'idCard',
			type: 'input',
			span: 6,
		},
		{
			label: '单位地区',
			prop: 'unitAreas',
			propName: 'unitAddress',
			type: 'AplidAreaSelect',
			span: 6,
		},
		{
			label: '姓名',
			prop: 'practitionersName',
			type: 'input',
			span: 6,
		},
		{
			label: '联系方式',
			prop: 'phone',
			type: 'input',
			span: 6,
		},
		{
			label: '职业类型',
			prop: 'occupationType',
			type: 'remoteSelect',
			code: 'OCCUPATION_TYPE',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			span: 6,
		},
		{
			label: '学历',
			prop: 'cultureDegree',
			type: 'remoteSelect',
			code: 'EDUCATION_DEGREE',
			api: 'getDictItemList',
			filterKey: 'value',
			multiple: false,
			span: 6,
		},
		{
			label: '更新状态',
			prop: 'staffStatus',
			type: 'select',
			dicData: [
				{ label: '正常', value: '正常' },
				{ label: '新入职', value: '新入职' },
				{ label: '离职', value: '离职' },
			],
			span: 6,
		},
	],
}

export const tableConfig = {
	stripe: true,
	border: true,
	columns: [
		{ label: '身份证号', prop: 'idCard', plusXing: '2,2' },
		{ label: '姓名', prop: 'practitionersName' },
		{ label: '联系方式', prop: 'phone', plusXing: '5,2' },
		{
			label: '专职',
			prop: 'workTypeLabel',
			span: 8,
		},
		{
			label: '职业类型',
			prop: 'occupationTypeLabel',
		},
		{
			label: '查看状态',
			prop: 'viewStatus',
			span: 8,
		},
		{
			label: '员工状态',
			prop: 'staffStatus',
			span: 8,
			dicData: [
				{ label: '正常', value: '正常' },
				{ label: '新入职', value: '新入职' },
				{ label: '离职', value: '离职' },
			],
		},
		{
			label: '操作',
			prop: 'menu',
			width: 300,
			fixed: 'right',
		},
	],
}

export const api = {
	index: 'view_dpFoundationPractitioners_monthPage',
}
export const baseConfig = {
	pageName: '员工信息',
	dictcodes: [''],
	rowKey: 'id',
	tipLabel: 'name',
	exportMqTopic: '/ning/export/',
	showHeaderTitle: false,
	api,
	auth: {
		...api,
	},
	menuBtn: [
		{
			icon: 'detail',
			label: '查看档案',
			type: 'primary',
			operate: 'Archives',
			auth: '',
			text: true,
			show: true,
		},
	],
	dialogConfig: {
		width: '75%',
	},
	detailConfig,
	searchConfig,
	tableConfig,
	beforeOnLoadFormate: async (params) => {
		const unitAreaIds: any = getAreaObj(params.unitAreas, 'unit')
		const unitAreaNames: any = getAreaObj(params.unitAddress, 'unit')
		
		return Promise.resolve({
			...params,
			...unitAreaIds,
			...unitAreaNames,
			unitAreas: undefined,
			unitAreasName: undefined,
		})
	},
}
